<?php
require_once '../include/includefiles.php';
?>
<?php
  $act = $_GET['act'];
  if($act=='reg'){
  	  if($_POST['verifycode']!=$_SESSION['VCODE']){
  	  	  alertmsg('验证码不正确，请重新输入!');
  	  }
  	  $username = $_POST['username'];
  	  $pass = $_POST['pass'];
  	  $pass1 = $_POST['pass1'];
  	  if($username=='') alertmsg('用户名不能为空!');
  	  if($pass=='') alertmsg('密码不能为空!');
  	  if($pass1=='') alertmsg('确认密码不能为空!');
  	  if($pass!=$pass1) alertmsg('密码不一致!');
  	  reguser($username,$pass);
  }else if($act=="login"){
      if($_POST['verifycode']!=$_SESSION['VCODE']){
  	  	  alertmsg('验证码不正确，请重新输入!');
  	  }
  	   $username = $_POST['username'];
  	   $pass = $_POST['pass'];
  	   loginuser($username,$pass);
  }else if($act=='user_seach'){
  	$user = $_POST['user'];
  	echo "<script>window.location='users.php?user=".$user."'</script>";
  }else if($act=='art_seach'){
  	$user = $_POST['user'];
  	echo "<script>window.location='article.php?user=".$user."'</script>";
  }else if($act=='role_seach'){
  	$user = $_POST['user'];
  	echo "<script>window.location='roles.php?user=".$user."'</script>";
  }else if($act=='user_role_seach'){
  	$user = $_POST['user'];
  	$role = $_POST['role'];
  	echo "<script>window.location='user_role.php?user=".$user."&role=".$role."'</script>";
  }
  else if($act=='role_menu_seach'){
  	$menu = $_POST['user'];
  	$role = $_POST['role'];
  	echo "<script>window.location='role_menu.php?user=".$menu."&role=".$role."'</script>";
  }
  
  else if($act=='user_del'){
  	  $ids = $_GET['ids'];
  	  delusers($ids);
  }else if($act=='art_del'){
  	  $ids = $_GET['ids'];
  	  delart($ids);
  }
  else if($act=='role_del'){
  	  $ids = $_GET['ids'];
  	  delroles($ids);
  }else if($act=='user_del1'){
  	  $id = $_GET['id'];
  	  deluser($id);
  }else if($act=='art_del1'){
  	  $id = $_GET['id'];
  	  delart1($id);
  }
  else if($act=='role_del1'){
  	  $id = $_GET['id'];
  	  delrole($id);
  }else if($act=='user_update'){
  	  $id = $_GET['id'];
  	  echo "<script>window.location='user_update.php?id=".$id."'</script>";
  }else if($act=='role_update'){
  	  $id = $_GET['id'];
  	  echo "<script>window.location='role_update.php?id=".$id."'</script>";
  }else if($act=='user_updatesubmit'){
  	  $uid = $_POST['uid'];
  	  $uname = $_POST['name'];
  	  updateuser($uid,$uname);
  }else if($act=='role_updatesubmit'){
  	  $uid = $_POST['uid'];
  	  $uname = $_POST['name'];
  	  updaterole($uid,$uname);
  }else if($act=='role_add'){
  	  $name = $_POST['name'];
  	  role_add($name);
  }else if($act=='menutree'){
  	  menutree(-1,0);
  }else if($act=='coltree'){
  	  $id=$_GET['id'];
  	  coltree(-1,0,$id);
  }
  else if($act=='menutree1'){
  	  $id=$_GET['id'];
  	  $pid = menufatherid($id);
  	  menutree1(-1,0,$pid);
  }else if($act=='menutree2'){
  	  $id=$_GET['id'];
  	  menutree1(-1,0,$id);
  }else if($act=='menuchange'){
  	$id = $_GET['id'];
  	if($id==-1){
  		alertmsg("请选择节点!");
  	}
  	jump("menus_update.php?id=".$id);
  }else if($act=='menu_update'){
  	$fid=$_POST['right'];
  	$mid = $_POST['mid'];
  	$name = $_POST['cmenu'];
  	$url = $_POST['url'];
  	updatemenu($mid,$name,$fid,$url);
  }else if($act=='menuadd'){
  	$id = $_GET['id'];
  	jump("menus_add.php?id=".$id);
  }else if($act=='menu_addsubmit'){
  	$fid=$_POST['right'];
  	$name = $_POST['name'];
  	$url = $_POST['url'];
  	menuadd($fid,$name,$url);
  }else if($act=='menudel'){
  	$id=$_GET['id'];
  	menudel($id);
  }else if($act=='user_role_add'){
  	$uid = $_POST['users'];
  	$rid = $_POST['roles'];
  	user_role_add($uid,$rid);
  }else if($act=='user_role_del'){
  	 $ids = $_GET['ids'];
  	  deluserrole($ids);
  }else if($act=='user_role_del1'){
  	  $id = $_GET['id'];
  	  deluserrole1($id);
  }else if($act=='user_menu_del1'){
  	  $id = $_GET['id'];
  	  delrolemenu1($id);
  }else if($act=='role_menu_del'){
  	 $ids = $_GET['ids'];
  	  delrolemenu($ids);
  }else if($act=='role_menu_add'){
  	 $role = $_POST['roles'];
  	 $right = $_POST['right'];
  	 role_menu_add($role,$right);
  }else if($act=='user_modify'){
  	 $user = $_POST['name'];
  	 $pass = $_POST['pass'];
  	 $newpass = $_POST['pass1'];
  	 modifyuser($user,$pass,$newpass);
  }
?>